package day04;

import java.util.Scanner;

public class Guessing {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = (int) (Math.random() * 1000 + 1);//随机数Math.random() 0.0-0.999999...
                                                   //要0-1000之间需先乘1000在加1，强转后得到1-1000
        System.out.println("请猜数字");
        int guess;
        do{
            guess = scan.nextInt();
            if(num<guess){
                System.out.println("猜大了");
                System.out.println("继续猜");
            } else if(num>guess){
                System.out.println("猜小了");
                System.out.println("继续猜");
            }else{
                System.out.println("恭喜猜对");
            }

        }while (guess!=num);



        /*
        int guess = scan.nextInt();
        while (num != guess) {
            String str = num > guess ? "猜小了" : "猜大了";
            System.out.println(str);
            System.out.println("继续");
            guess = scan.nextInt();
        }
        System.out.println("恭喜你猜对了!");
         */
    }
}
